//过滤器
export function nullFilters(row) {
	if (row == null) {
		return ''
	} else {
		return row
	}
}

export function nullNums(row) {
	if (row == null) {
		return '0'
	} else {
		return row
	}
}

export function formatSex(row) {
	if (row == '1') {
		return '男'
	} else if (row == '2') {
		return '女'
	}else{
		return '未知'
	}
	
}

//手机号
export function formatPhone(phone) {
	if (phone && phone.length > 6) {
		const len = phone.length
		phone = phone.substr(0, 3) + '****' + phone.substr(len - 4, len - 1)
		return phone
	}
}

//json名称置顶
export function getJsonName(json) {
	if (json) {
		let obj = JSON.parse(json);
		let name = obj[0].name;
		if (name) {
			return obj[0].name;
		} else {
			return
		}
	}
}


/*  时间处理   年月日yyyy-MM-dd */
export function normalDate(time) {
	if (time == null || time === '') {
		return '暂无数据'
	}
	time = time.substring(0, 10)
	return time
}

/*  时间处理   年月日-时分秒yyyy-MM-dd hh:mm:ss */
export function normalTime(time) {
	if (time == null || time === '') {
		return '暂无数据'
	}
	return time
}
//CheckInStatus:''  //1.已签到  2.未签到   3.已请假
export function getCheckInStatus(CheckInStatus) {
	let status = '';
	if (CheckInStatus == "1") {
		status = "已签到";
	} else if (CheckInStatus == '3') {
		status = "已请假";
	} else if (CheckInStatus == '2') {
		status = "未签到";
	}
	return status;
}
//courseStatus 课程状态1.进行中 2.已结束 0.未开始
export function courseStatus(courseStatus) {
	let status = '';
	if (courseStatus == "1") {
		status = "进行中";
	} else if (courseStatus == '2') {
		status = "已结束";
	} else if (courseStatus == '0') {
		status = "未开始";
	}
	return status;
}

//courseStatus 课程状态1.进行中 2.已结束 0.未开始
export function kaoheStatus(kaoheStatus) {
	let status = '';
	if (kaoheStatus == "20") {
		status = "进行中";
	} else if (kaoheStatus == '30') {
		status = "已结束";
	} else {
		status = "";
	}
	return status;
}
//题目过滤
export function subType(obj) {
	if (obj === "radio") {
		return '单选题'
	}

	if (obj === "checkbox") {
		return '多选题'
	}

	if (obj === "true_false") {
		return '判断题'
	}
	return ''

}

//获取文件名称
//适用于格式为  files/20200505/xxxxx_15019203123123.xxx
export function getFileName(text) {
	if (!text || text.toString().indexOf('_') === -1) {
		return text
	}
	return text.toString().substring(0, text.lastIndexOf('_'))
}
